<{if count($trading.products)>0 || count($trading.package)>0 || count($trading.gift_e)>0 }>
<div class="CartWrap" id="cart-index">
<div class="CartNav clearfix"><div class="floatLeft"><img src="statics/cartnav-step1.gif" alt="购物流程--查看购物车" /></div><div class="floatRight"><img src="statics/cartnav-cart.gif"  /></div></div>
<{if count($trading.products)>0 || count($trading.package)>0 || count($trading.gift_e)>0 }>
  <div class="section" id="cart-items">
  <form id="form-cart" action="<{link ctl="cart" act="checkout"}>" method="post" extra="cart">
  <div class="FormWrap" id="cartItems">
    <{if count($trading.products) > 0}>
    <h3><{t}>已放入购物车的商品:<{/t}></h3>
    <div id="goodsbody" class="division">
    <table width="100%" cellpadding="3" cellspacing="0" class="liststyle">
      <col class="span-2 "></col>
      <col class="span-auto"></col>
      <col class="span-2"></col>
      <col class="span-2"></col>
      <col class="span-2"></col>
      <!--<col class="span-1"></col>-->
      <col class="span-2 ColColorOrange"></col>
      <col class="span-2"></col>
      <thead>
        <tr>
          <th><{t}>图片<{/t}></th>
          <th><{t}>商品名称<{/t}></th>
          <th><{t}>商品积分<{/t}></th>
          <th><{t}>销售价格<{/t}></th>
          <th><{t}>优惠价格<{/t}></th>
          <th style="display:none;"><{t}>数量<{/t}></th>
          <th><{t}>小计<{/t}></th>
          <th><{t}>删除<{/t}></th>
        </tr>
      </thead>
      <tbody >
      <{foreach from=$trading.products item="item" key="key"}>
      <tr number="<{$item.nums}>" urlupdate="<{link ctl=cart act=updateCart arg0=g arg1=$item.key}>" urlremove="<{link ctl=cart act=removeCart arg0=g}>" >
        <td><a href='<{link ctl=product act=index arg0=$item.goods_id}>' target='_blank' style='margin:0;padding:0;text-decoration:none;'>
             <span class='cart-product-img' isrc="<{$item.thumbnail_pic|gimage:'thumbnail'}>" style='display:block;width:50px;height:50px;'>
                <img src='statics/loading.gif'/>
             </span>
           </a>
        </td>
        <td style='text-align:left'><a href='<{link ctl=product act=index arg0=$item.goods_id}>' target='_blank'><{$item.name}><{if $item.spec}> (<{$item.spec}>)<{/if}><{$item.addon.adjname}>
          <{if $item._pmt.describe}><div class="ht1"><{$item._pmt.describe}></div><{/if}></a></td>
        <td><{$item._pmt.score|string_format:"%d"}></td>
        <td class=" mktprice1"><{$item.sale_price|cur}></td>
        <td><{$item._pmt.price|cur}></td>
        <td style="display:none;">
          <div class="Numinput">
            <input type="text" class="_x_ipt textcenter" value="<{$item.nums}>" onchange="Cart.inputUpdate(event)" size="3" name="cartNum[g][<{$item.key}>]" /><span class="numadjust increase" price="<{$item._pmt.price|cur:'':true:true}>"></span><span class="numadjust decrease" price="<{$item._pmt.price|cur:'':true:true}>"></span></div><{if !is_null($item.store) && $item.nums > $item.store}><h3 class="t"><{t}>(提示:需要备货)<{/t}></h3><{/if}></td>
        <td class="itemTotal"><{$item._pmt.amount|cur}></td>
        <td><span class="lnk quiet"><{t}>删除<{/t}></span></td>
      </tr>
      <{/foreach}>
      </tbody>
    </table>
    </div>
    <{/if}>

    <{if $trading.gift_e}>
    <h3><{t}>赠品<{/t}></h3>
    <div id="giftbody"  class="division" >
    <table width="100%" cellpadding="0" cellspacing="0" class="liststyle" >
      <col class="span-2"></col>
      <col></col>
      <col class="span-2"></col>
      <col class="span-2 "></col>
      <col class="span-1"></col>
      <col class="span-2 ColColorOrange"></col>
      <col class="span-2"></col>            
      <thead>
        <tr>
          <th><{t}>图片<{/t}></th>
          <th><{t}>赠品名称<{/t}></th>
          <th><{t}>所需积分<{/t}></th>
          <th><{t}>限购数量<{/t}></th>
          <th><{t}>数量<{/t}></th>
          <th><{t}>小计<{/t}></th>
          <th><{t}>删除<{/t}></th>
        </tr>
      </thead>
      <tbody >
      <{foreach from=$trading.gift_e item="item" key="key"}>
        <tr number="<{$item.nums}>" urlupdate="<{link ctl=cart act=updateCart arg0=f arg1=$item.gift_id}>" urlremove="<{link ctl=cart act=removeCart arg0=f}>">
          <td><a href="<{link ctl=gift act=index arg0=$item.gift_id}>" target='_blank' style='margin:0;padding:0;text-decoration:none;'><img src="<{$item.thumbnail_pic|gimage:'thumbnail'}>"  <{if $env.thumbnail_pic_width >0 && $env.thumbnail_pic_height >0}>width="<{$env.thumbnail_pic_width}>" height="<{$env.thumbnail_pic_height}>"<{/if}> /></a></td>
          <td style='text-align:left'><a href="<{link ctl=gift act=index arg0=$item.gift_id}>" target='_blank'><{$item.name}></a></td>
          <td><{$item.point}></td>
          <td><{if $item.limit_num=='0'}><{t}>不限制<{/t}><{else}><{$item.limit_num}><{/if}></td>
          <td><div class="Numinput"><input type="text" class="_x_ipt textcenter" onchange="Cart.inputUpdate(event)" value=<{$item.nums}> size="3" name="cartNum[f][<{$item.gift_id}>]" ><span class="numadjust increase" point="<{$item.point}>"></span><span class="numadjust decrease" point="<{$item.point}>"></span></div></td>
          <td class="itemTotal"><{$item.amount}></td>
          <td><span class="lnk quiet"><{t}>删除<{/t}></span></td>                    
        </tr>
      <{/foreach}>
      </tbody>
    </table>
    </div>
    <{/if}>
    
    <{if $trading.package}>
    <h3><{t}>捆绑商品<{/t}></h3> 
    <div id="pkgbody"  class="division"> 
    <table width="100%" cellpadding="0" cellspacing="0" class="liststyle">
      <col class="span-2"></col>
      <col style="width:auto;"></col>
      <col class="span-2 "></col>
      <col class="span-1"></col>
      <col class="span-2 ColColorOrange"></col>
      <col class="span-2"></col>                
      <thead>
        <tr>
          <th><{t}>货号<{/t}></th>
          <th><{t}>捆绑名称<{/t}></th>
          <th><{t}>优惠价格<{/t}></th>
          <th><{t}>数量<{/t}></th>
          <th><{t}>小计<{/t}></th>
          <th><{t}>删除<{/t}></th>                        
        </tr>
      </thead>
      <tbody>
      <{foreach from=$trading.package item=item key=key}>
        <tr number="<{$item.nums}>" urlupdate="<{link ctl=cart act=updateCart arg0=p arg1=$item.goods_id}>" urlremove="<{link ctl=cart act=removeCart arg0=p}>">
          <td><{$item.bn}></td>
          <td style='text-align:left'><a href='<{link ctl=package act=index}>' target='_blank'><{$item.name}> <{$item.addon.adjname}></a></td>
          <td><{$item.price|cur}></td>
          <td><div class="Numinput"><input type="text" class="_x_ipt textcenter" onchange="Cart.inputUpdate(event)" value=<{$item.nums}> size="3" name="cartNum[p][<{$item.goods_id}>]" ><span class="numadjust increase" price="<{$item.price|cur:'':true:true}>"></span><span class="numadjust decrease" price="<{$item.price|cur:'':true:true}>"></span></div></td>
          <td class="itemTotal"><{$item.amount|cur}></td>
          <td><span class="lnk quiet"><{t}>删除<{/t}></span></td>    
        </tr>
      <{/foreach}>
      </tbody>
    </table>
    </div>
    <{/if}>
    
    <div class="division" id="cartTotal">
    <{require file="cart/cart_total.html"}>
    </div>
  </div>
  
  <div class="CartBtn clearfix" style="margin-bottom:5px;">
  <div class="span-auto"><input type="button" class="btn-return actbtn" style="width:90px" onclick="window.location='<{link ctl=index}>'" value="<{t}>&laquo;继续购物<{/t}>"></div>
  <div class="span-auto"><input id="clearCart" url="<{link ctl=cart act=removeCart arg0=all}>" class="btn-clearcat actbtn" style="width:90px"  type="button" value="清空购物车" /></div>
  <div class="span-auto floatRight"><input class="btn-next actbtn" type="submit" value="<{t}>下单结算&raquo;<{/t}>" /></div>
  </div>
  </form>
  </div>
<form action="<{link ctl="cart" act="applycoupon"}>" method="post" id="cart-coupon">
<div class="FormWrap">
<h3 ><{t}>使用优惠券<{/t}></h3>
<div class="division">
  <{if count($trading.coupon_u)>0}>
  <div class="promotion"><{t}>使用的优惠券：<{/t}><{foreach from=$trading.coupon_u item="item" key="key"}><strong><{$key}></strong><{/foreach}><a href="<{link ctl=cart act=removeCoupon}>" class="lnk" style="margin:0 0 0 20px;"><{t}>取消优惠券<{/t}></a></div>
  <{else}>
  <{input type="text" name="coupon" id="-s-ipt-coupon" size="30"}> <input type="submit" value="<{t}>输入优惠券号码<{/t}>" />
  <{/if}>
</div>
</div>
</form>
<{/if}>

<div id="cart-none-msg" style='<{if count($trading.products)>0 || count($trading.package)>0 || count($trading.gift_e)>0 }>display:none;<{/if}>'>
<br/>
<br/>
<div  class='success' >您已清空了购物车.</div>
<h3>现在您可以:</h3>
<ul class='list'>
   <li><a href='<{link ctl="index" act="index"}>'>返回网站首页</a></li>
   <li><a href='javascript:opener=null;window.close();'>关闭此页面</a></li>
</ul>

</div>

</div>
<script language="javascript">
window.addEvent('domready',function(){
 
  var cart_product_img_viewer=new Element('div',{styles:{'position':'absolute','zIndex':500,'opacity':0,'border':'1px #666 solid'}}).inject(document.body);
  
  var cpiv_show=function(img,event){
       
      if(!img)return;
      cart_product_img_viewer.empty().adopt($(img).clone().removeProperties('width','height').setStyle('border','1px #fff solid')).fade(1);
      
      var size = window.getSize(), scroll = window.getScroll();
        var tip = {x: cart_product_img_viewer.offsetWidth, y: cart_product_img_viewer.offsetHeight};
        var props = {x: 'left', y: 'top'};
        for (var z in props){
            var pos = event.page[z] + 10;
            if ((pos + tip[z] - scroll[z]) > size[z]) pos = event.page[z] - 10 - tip[z];
            cart_product_img_viewer.setStyle(props[z], pos);
        }
  
  };
  
  
   $ES('#cart-index .cart-product-img').each(function(i){
       new Asset.image(i.get('isrc'),{onload:function(img){
	   if(!img)return;
           var _img=img.zoomImg(50,50);
		     if(!_img)return;
           _img.setStyle('cursor','pointer').addEvents({
              'mouseenter':function(e){
                 cpiv_show(_img,e);
              },
              'mouseleave':function(e){
                cart_product_img_viewer.fade(0);
              }
           });
           i.empty().adopt(_img);                 
       },onerror:function(){
            i.empty();
		
       }});
   
   });
   
   
});

if(!extra_validator['cart']){
  extra_validator['cart'] ={
    'cartnum':['请录入大于0的整数',function(f,i){
        return (i>0)&&(!/[^\d]/.test(i));
      }]
    };
}
var moneyFormat = <{$currency|default:'null'}>;
         $$('#cartItems .numadjust').addEvents({
             'mousedown':function(){
                this.addClass('active');
             },
             'mouseup':function(){
               this.removeClass('active');
             }
         });
</script>
<{else}>
   <p id="cart-none-msg">
       <div class='notice'><{t}>您好,您的购物车没有加入任何商品!.<{/t}></div>
       <h3>现在您可以:</h3>
        <ul class='list'>
           <li><a href='<{link ctl="index" act="index"}>'>返回网站首页</a></li>
           <li><a href='javascript:opener=null;window.close();'>关闭此页面</a></li>
       </ul>
   </p>
<{/if}>

